'use strict';

const BasicController = require("./basic");
const MD5 = require("md5");
class LayoutController extends BasicController {
      async add() {
            const { request, model } = this.ctx;
            let { layoutDesign, layoutName } = request.body;
            layoutDesign = JSON.stringify(layoutDesign);
            const layoutInfo = await model.Layouts.create({ layoutDesign, layoutName });

            this.success({ layoutId: layoutInfo._id });
      }

      async show() {
            const { query, model } = this.ctx;
            try {
                  const layoutInfo = await model.Layouts.findById({ "_id": query.id });
                  this.success(layoutInfo)
            } catch (error) {
                  this.error(error)
            }
      }
}

module.exports = LayoutController;
